<template>
  <div class="fwfl-con">
    <template v-if="rateType != '1'">

      <div :key="index+''" class="fwfl-item" v-for="(item,index) in dataList_">
        {{getVal(item.min,'1') +'元 ＜ 开票金额 ≤ '+getVal(item.max,'1') + '  元，服务费率： ' + getVal(item.rate,'2')  +" %"}}
      </div>
    </template>
    <template v-if="rateType == '1'">
      {{getVal(dataList_[0] && dataList_[0].rate,'2')  +" %"}}
    </template>
  </div>
</template>

<script>
import * as Utils from '@/utils/util'
// {1:'固定费率',2:'阶梯费率',3:'累进阶梯'}
export default {
  name: 'FWFL',
  props:{
    dataList:{type:Object},
  },
  data() {
    return {
      rateType:'1',
      dataList_: [
        // { "id": 1, "confId": 1312, "min": 0, "max": 20000, "rate": 0.05, "createBy": "李重庆", "createById": -1, "createTime": "2022-11-17 10:24:57", "updateById": -1, "updateBy": "李重庆", "updateTime": "2022-11-21 15:27:25" },
        // { "id": 2, "confId": 1312, "min": 20000, "max": 3000000, "rate": 0.05, "createBy": "李重庆", "createById": -1, "createTime": "2022-11-17 10:24:57", "updateById": -1, "updateBy": "李重庆", "updateTime": "2022-11-21 15:28:12" },
        // { "id": 3, "confId": 1312, "min": 20000, "max": 3000000, "rate": 0.05, "createBy": "李重庆", "createById": -1, "createTime": "2022-11-17 10:24:57", "updateById": -1, "updateBy": "李重庆", "updateTime": "2022-11-21 15:28:12" },
        // { "id": 5, "confId": 1312, "min": 1000000, "max": 10000000, "rate": 0.05, "createBy": "李重庆", "createById": -1, "createTime": "2022-11-17 10:24:57", "updateById": -1, "updateBy": "李重庆", "updateTime": "2022-11-21 15:27:54" }
      ]

    }
  },
  watch: {
    dataList: {
      handler(val) {
        if (Object.prototype.toString.call(val) === '[object Object]') {
          const {value} = val
          this.dataList_ =value.d
          this.rateType = value.rateType
        }
        console.log('formConfig watch ==>',val);
      },
      deep: true,
      immediate: true
    },
  },
  methods:{
    getVal(val,type){
      let res = ''
      if(type==='1'){
        res = Utils.conversionElement(val) // percentConversion
      }
      if(type==='2'){
        res = Utils.percentConversion(val)
      }
      if(isNaN(res)){
        res = '--'
      }
      return res
    }
  }
}
</script>

<style>

</style>
